//
//  MyRatioTool.m
//  DeepBreath
//
//  Created by rimi on 15/9/15.
//  Copyright (c) 2015年 Liukai. All rights reserved.
//

#import "MyRatioTool.h"
#import <UIKit/UIKit.h>
#import <CoreGraphics/CoreGraphics.h>

#define SCREEN_W [UIScreen mainScreen].bounds.size.width
#define SCREEN_H [UIScreen mainScreen].bounds.size.height

@implementation MyRatioTool

- (CGRect)initWithRect:(CGRect)rect {
    CGPoint pointer = CGPointMake(rect.origin.x + rect.size.width / 2, rect.origin.y +rect.size.height / 2);
    CGPoint currentCenter = [self initWithPointer:pointer];
    CGRect currentRect;
    currentRect.size.width = rect.size.width * [self LKFlexibleWidth];
    NSLog(@"wis%f",rect.size.width);
    currentRect.size.height = rect.size.height * [self LKFlexibleHeight];
    currentRect.origin.x = currentCenter.x - currentRect.size.width / 2;
    currentRect.origin.y = currentCenter.y - currentRect.size.height / 2;
    return currentRect;
    
}

- (CGFloat)LKFlexibleWidth {
    return SCREEN_W / WIDTH;
}

- (CGFloat)LKFlexibleHeight {
    return SCREEN_H / HEIGHT;
}

- (CGPoint)initWithPointer:(CGPoint)pointer {
    return CGPointMake(pointer.x * [self LKFlexibleWidth], pointer.y * [self LKFlexibleHeight]);
}

- (CGSize)initWithSize:(CGSize)size {
    return CGSizeMake(size.width * [self LKFlexibleWidth], size.height * [self LKFlexibleWidth]);
}
@end
